package com.fwj.base.handler;

import com.fwj.base.entity.R;
import com.fwj.base.exception.CustomException;
import lombok.extern.slf4j.Slf4j;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.servlet.mvc.method.annotation.ResponseEntityExceptionHandler;

/**
 * GlobalExceptionHandler
 * 全局异常处理器
 * @author 樊温军
 * @date 2025/3/22 上午11:23
 */
@Slf4j
@ControllerAdvice
@ResponseBody
public class GlobalExceptionHandler extends ResponseEntityExceptionHandler {

    @ExceptionHandler(CustomException.class)
    public R<Object> handleCustomException(CustomException ex) {
        return R.failed(ex);
    }
}
